package main

import (
	"fmt"
	"time"
)

func main() {

	c := make(chan int, 1)

	go func() {
		fmt.Println("写入数据， begin")
		time.Sleep(2 * time.Second)
		c <- 1
		fmt.Println("写入数据， end")
	}()

	fmt.Println("主等待, begin")
	select {
	case <-time.After(1 * time.Second):
		fmt.Println("等待超时")
	case <-c:
		fmt.Println("c, ok")
	}
	fmt.Println("主等待， end")
}
